library ieee;
 use ieee.std_logic_1164.all;
 use ieee.std_logic_unsigned.all;

library work;
 use work.router_pack.all;

-------------------------------------------------------------------------------
entity mutex_net_4_star is
-------------------------------------------------------------------------------
port( 
      -- MUTEX input i/f: --
      R       : in  std_logic_vector(mutex4_width_c-1 downto 0);

      -- MUTEX output i/f: --
      G       : out std_logic_vector(mutex4_width_c-1 downto 0)
);           
-------------------------------------------------------------------------------
end mutex_net_4_star ;
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
architecture mutex_net_4_star_arch of mutex_net_4_star is
-------------------------------------------------------------------------------
component mutex
port( 

      -- MUTEX input i/f: --
      R1      : in  std_logic;
      R2      : in  std_logic;

      -- MUTEX output i/f: --
      G1      : out std_logic;
      G2      : out std_logic
);           
end component;

signal stage_1_outs : std_logic_vector(3 downto 0);
signal stage_2_outs : std_logic_vector(3 downto 0);

begin

u_stage2_1: mutex
port map( 

      R1      => R(0),
      R2      => R(2),

      G1      => stage_2_outs(0),
      G2      => stage_2_outs(1)
);

u_stage2_2: mutex
port map( 

      R1      => R(1),
      R2      => R(3),

      G1      => stage_2_outs(2),
      G2      => stage_2_outs(3)
);


u_stage3_1: mutex
port map( 

      R1      => stage_2_outs(2),
      R2      => stage_2_outs(1),

      G1      => G(1),
      G2      => G(2)
);

u_stage3_2: mutex
port map( 

      R1      => stage_2_outs(0),
      R2      => stage_2_outs(3),

      G1      => G(0),
      G2      => G(3)
);

-------------------------------------------------------------------------------
end mutex_net_4_star_arch;
-------------------------------------------------------------------------------                 

   
-------------------------------------------------------------------------------
configuration  mutex_net_4_star_cfg  of mutex_net_4_star is
-------------------------------------------------------------------------------
   for mutex_net_4_star_arch
   end for;
-------------------------------------------------------------------------------
end  mutex_net_4_star_cfg;              
-------------------------------------------------------------------------------
                 
